﻿{include file="public/header" /}
			<form method="post">
				<div class="panel admin-panel">
					<div class="panel-head"><strong>{:lang('currency')['list']}</strong></div>
					<div class="padding border-bottom">
						<script>
						//city 参数和回调
						var pid="{:input('get.pid')}";
						var cid="{:input('get.cid')}";
						var aid="{:input('get.aid')}";
						var selectc=true;
						var selecta=true;
						function select_p(){
							return false;
						}
						function select_c(){
							return false;
						}
						function select_a(){
							var express_id = $("#express").val();
							var seller_id = $("#seller").val();
							var status = $("#status").val();
							location.href="{:url('/admin/order')}?pid="+pid+"&cid="+cid+"&aid="+aid+"&status="+status+"&seller_id="+seller_id+"&express_id="+express_id+"&start_time="+start_time+"&end_time="+end_time;
							//location.href="{:url('/admin/order')}?pid="+pid+"&cid="+cid+"&aid="+aid;
						}
						</script>
						{:lang('label')['select']}{:lang('currency')['city']}:{include file="public/city" /}
						订单状态：
						<select class="input input-auto" id="status">
							<option value="">请选择</option>
							{for start="1" end="8" step="1" name="i"} 
							<option {if $_GET['status'] == $i}selected{/if} value="{$i}">{:lang('label')['order_status_'.$i]}</option>
							{/for}
							<option {if $_GET['status'] == 8}selected{/if} value="8">待商家接单</option>
						</select>
						商家：
						<select class="input input-auto" id="seller">
							<option value="">请选择</option>
							{volist name="sellerlist" id="seller"}
							<option {if $_GET['seller_id'] == $seller.id}selected{/if} value="{$seller.id}">{$seller.name}</option>
							{/volist}
						</select>
						配送员：
						<select class="input input-auto" id="express">
							<option value="">请选择</option>
							{volist name="expresslist" id="express"}
							<option {if $_GET['express_id'] == $express.id}selected{/if} value="{$express.id}">{$express.name}</option>
							{/volist}
						</select>
						{css href="__ROOT__/static/admin/css/daterangepicker.css" /}
						{js href="__ROOT__/static/public/js/moment.js" /}
						{js href="__ROOT__/static/public/js/daterangepicker.js" /}
						<style>
							.daterangepicker{
								display:none;
								border: 1px solid #08C;
							}
						</style>
						<button type="button" class="button button-default pull-right" id="daterange-btn">
							<span>
							{if $_GET['start_time']}
							{$_GET['start_time']} 至 {$_GET['end_time']}
							{else}
							  <i class="icon-calendar"></i> 日期选择
							{/if}
							</span>
							<i class="icon-caret-down"></i>
						</button>
						<script>
							var start_time="{:input('get.start_time')}",end_time="{:input('get.end_time')}";
							$('#daterange-btn').daterangepicker({
									ranges: {
										'今天': [moment(), moment()],
										'本周': [moment().startOf('week'), moment().endOf('week')],
										'本月': [moment().startOf('month'), moment().endOf('month')],
										'今年': [moment().startOf('year'), moment().endOf('year')]
									},
									startDate: moment(),
									endDate: moment().endOf('month')
								},
								function(start, end) {
									start_time = start.format('YYYY-M-DD');
									end_time = end.format('YYYY-M-DD');
									$('#daterange-btn span').html(start_time + ' 至 ' + end_time);
								}
							);
						</script>
						<a type="button" class="button button border-yellow search_t" href="#" />
						{:lang('label')['search']}</a>
						 <a type="button" class="button button border-yellow search" href="#" />{:lang('label')['order_id']}
						{:lang('label')['search']}</a>
						<a href="?">取消搜索</a>
						<a class="button button border-blue" style="float: right;margin-right: 20px" href="javascript:dispatch('&aid={:input(\'get.aid\')}')">订单调度系统</a>
					</div>
					<table class="table table-hover">
						<tr>
							<th width="120">{:lang('label')['order_id']}</th>
							<th width="120">{:lang('label')['type']}</th>
							<th width="120">{:lang('label')['seller']}</th>
							<th width="120">{:lang('label')['phone']}</th>
							<th width="100">满减</th>
							<th width="30">首减</th>
							<th width="30">{:lang('label')['price']}</th>
							<th width="50">{:lang('label')['name']}</th>
							<th width="100">{:lang('label')['phone']}</th>
							<th width="100">{:lang('label')['address']}</th>
							<th width="50">{:lang('label')['status']}</th>
							<th width="50">{:lang('label')['express']}</th>
							<th width="100">下单{:lang('label')['time']}</th>
							<th width="100">{:lang('label')['finish']}{:lang('label')['time']}</th>
							<th width="100">{:lang('label')['handle']}</th>
						</tr>
						{volist name="data" id="order"}
						<tr>
							<td>{$order.order_id}</td>
							<td style="line-height:40px">{if $order.type == 0}外卖{else}到店{/if}</td>
							<td style="line-height:40px">{if $order.advance != 0}<font style="color: red;">【预定】</font>{/if}{$order.title}</td>
							<td style="line-height:40px">{$order.sellerphone}</td>
							<td style="line-height:40px">{if $order.money_off_text}{$order.money_off_text}{else}无{/if}</td>
							<td style="line-height:40px">{if $order.new_user_reduction}{$order.new_user_reduction}{else}无{/if}</td>
							<td style="line-height:40px">{$order.last_price}</td>
							<td style="line-height:40px">{$order.name}</td>
							<td style="line-height:40px">{$order.phone}</td>
							<td style="line-height:40px">{$order.address}</td>
							{if $order.type == 0}
							<td style="line-height:40px">{if $order.status == "1"}<span class="text-red">{:lang('label')['order_status_1']}</span>{elseif $order.status != 2 || $order.advance_receive != 0}<span class="text-sub">{:lang('label')['order_status_'.$order.status]}</span>{else}等待商家接单{/if}</td>
							<td style="line-height:40px">{$order.express_name}</td>
							{else}
							<td style="line-height:40px">{if $order.status == "1"}<span class="text-red">{:lang('label')['order_status_1']}</span>{elseif $order.status != 2 || $order.advance_receive != 0}<span class="text-sub">{:lang('label')['order_status_'.$order.status]}</span>{else}等待商家接单{/if}</td>
							<td style="line-height:40px">{$order.express_name}</td>
							{/if}
							<td style="line-height:40px">{$order.time|date="Y-m-d H:i",###}</td>
							<td style="line-height:40px">{if $order.complete_time}{$order.complete_time|date="Y-m-d H:i",###}{else}未完成{/if}</td>
							<td style="line-height:40px">
								<a class="button border-blue button-little" href="javascript:show_detail('{$order.order_id}')">{:lang('currency')['detail']}</a>
								{if $order.status >= 2 && $order.status <= 4}
									<a class="button border-yellow button-little" href="__URL__/?cancel=ok&order_id={$order.order_id}&page={$pages.page}" onclick="if(!confirm('确认取消该订单？'))return false;">取消</a>
								{/if}
							</td>
						</tr>
						{/volist}
					</table>
					{include file="public/pages" /}
				</div>
			</form>
			<script>
			layer.config({
				extend: 'extend/layer.ext.js'
			});
			var last_time = "{$last_time}";
			function update_order() {
				$.post("__URL__/socket?type=order&aid={:input('get.aid')}",{},function (newtime) {
					if(newtime > last_time){
						layer.msg('订单列表发生变化！');
						refrush();
					}
				})
			}

			function auto() {
				update_order();
				setTimeout(function () {
					auto();
				},30000);
			}
			auto();

			function refrush() {
				setTimeout(function () {
					window.location.reload();
				},700)
			}
			$('#select_del').click(function(){
				var str=""; 
				$("input:checkbox[name=id]:checked").each(function(){ 
					str+=$(this).val()+",";
				});
				if(str!=''){
					if(confirm("{:lang('currency')['del']}?")){location.href='order/del.html?id='+str;}
				}
			});
            function dispatch(order_id) {
                parent.layer.open({
                    type: 2,
                    title:'订单调度系统',
                    area: ['100%', '100%'], //宽高
                    maxmin: true,
                    shade : false,
                    content: '__URL__/dispatch?order_id='+order_id
                });
            }
			function  show_detail(order_id) {
                layer.open({
                    type: 2,
                    title:'订单详情',
                    //skin: 'layui-layer-rim', //加上边框
                    area: ['500px', '600px'], //宽高
                    content: '__URL__/detail.html?order_id='+order_id
                });
            }
			$('.search').click(function(){
				layer.prompt({title:'{:lang('label')['order_id']}{:lang('label')['search']}'},function(val){
					location.href="__ROOT__/admin/order.html?order_id="+val;
				});
			});
			$('.search_t').click(function(){
				var express_id = $("#express").val();
				var seller_id = $("#seller").val();
				var status = $("#status").val();
				location.href="{:url('/admin/order')}?pid="+pid+"&cid="+cid+"&aid="+aid+"&status="+status+"&seller_id="+seller_id+"&express_id="+express_id+"&start_time="+start_time+"&end_time="+end_time;
			});
			</script>
{include file="public/footer" /}